package Game.Spawners;

import java.util.ArrayList;
import java.util.List;

import org.newdawn.slick.SlickException;

import Game.Level;
import Game.Objects.GOAltar;
import Game.Objects.GOAnvil;
import Game.Objects.GameObject;
import GameMath.GPoint;

/** Spawn Altar class
 * @author Aikidos
 */
public class SpawnAnvil extends SpawnerBase {

	@Override
	public void spawn(Level level) throws SlickException {
		List<GPoint> banCoords = new ArrayList<GPoint>();
		banCoords.add(level.getObjectManager().getPlayer().getCoord());
		
		if (!level.isUndergroundTown())
			banCoords.add(level.getObjectManager().getObjectsByClass("Game.Objects.GOLever")[0].getCoord());
		
		banCoords.add(level.getObjectManager().getObjectsByClass("Game.Objects.GOTrapdoor")[0].getCoord());
		
		// Doors
		GameObject[] doors = level.getObjectManager().getObjectsByClass(
				"Game.Objects.GODoor");
		for (GameObject door : doors) {
			banCoords.add(door.getCoord());
		}

		// Keys
		GameObject[] keys = level.getObjectManager().getObjectsByClass(
				"Game.Objects.GODoorKey");
		for (GameObject key : keys) {
			banCoords.add(key.getCoord());
		}

		// Chests
		GameObject[] chests = level.getObjectManager().getObjectsByClass(
				"Game.Objects.GOGoldChest");
		for (GameObject chest : chests) {
			banCoords.add(chest.getCoord());
		}

		// Torches
		GameObject[] torches = level.getObjectManager().getObjectsByClass(
				"Game.Objects.GOTorch");
		for (GameObject torch : torches) {
			banCoords.add(torch.getCoord());
		}

		// Other barrels
		GameObject[] barrels = level.getObjectManager().getObjectsByClass(
				"Game.Objects.GOBarrel");
		for (GameObject barrel : barrels) {
			banCoords.add(barrel.getCoord());
		}
		
		level.getObjectManager().spawnObject(new GOAnvil(level.getObjectManager()), banCoords);
	}
	
}
